function canJump(nums: number[]): boolean {
    let endReachable:number = nums.length-1;
    for(let index=nums.length-1; index>=0;index--){
        if(nums[index] + index >= endReachable){
            endReachable = index;
        }
    }
    return endReachable === 0;
};

function canJump2(nums: number[]): boolean {
    let endReachable:number = 0;
    for(let index=0;index<nums.length; index++){
        if(index>endReachable){
            return false;
        }
        endReachable = Math.max(endReachable, index+nums[index]);
    }

    return true;
};